//
// Created by Administrator on 2020/10/21.
//

#ifndef O5G_SRC_CCORE_PHY_RF_INCLUDE_RFAPI_H_
#define O5G_SRC_CCORE_PHY_RF_INCLUDE_RFAPI_H_

#include "rfDef.h"

#ifdef __cplusplus
extern "C"
{
#endif

int rf_open(rf_t* h, char* args);

int rf_open_multi(rf_t* h, char* args, uint32_t nof_channels);

int rf_open_devname(rf_t* h, const char* devname, char* args, uint32_t nof_channels);

const char* rf_name(rf_t* h);

int rf_start_gain_thread(rf_t* rf, int8_t tx_gain_same_rx);

int rf_close(rf_t* h);

int rf_start_rx_stream(rf_t* h, int8_t now);

int rf_stop_rx_stream(rf_t* h);

void rf_flush_buffer(rf_t* h);

int8_t rf_has_rssi(rf_t* h);

float rf_get_rssi(rf_t* h);

double rf_set_rx_srate(rf_t* h, double freq);

double rf_set_rx_gain(rf_t* h, double gain);

void rf_set_tx_rx_gain_offset(rf_t* h, double offset);

double rf_set_rx_gain_th(rf_t* h, double gain);

double rf_get_rx_gain(rf_t* h);

double rf_get_tx_gain(rf_t* h);

rf_info_t * rf_get_info(rf_t *h);

void rf_suppress_stdout(rf_t *h);

void rf_register_error_handler(rf_t *h, rf_error_handler_t error_handler , void* arg ) ;

double rf_set_rx_freq(rf_t *h, uint32_t ch , double freq ) ;

int rf_recv(rf_t *h, void * data, uint32_t nsamples , int8_t blocking ) ;

int rf_recv_with_time(rf_t *h, void * data, uint32_t nsamples , int8_t blocking, time_t * secs , double* frac_secs ) ;

int rf_recv_with_time_multi(rf_t *h, void * *data, uint32_t nsamples , int8_t blocking, time_t * secs , double* frac_secs ) ;

double rf_set_tx_srate(rf_t *h, double freq ) ;

double rf_set_tx_gain(rf_t *h, double gain) ;

double rf_set_tx_freq(rf_t *h, uint32_t ch , double freq ) ;

void rf_get_time(rf_t *h, time_t * secs, double * frac_secs);

int rf_sync(rf_t *rf);

int rf_send(rf_t *h, void * data, uint32_t nsamples , int8_t blocking ) ;

int rf_send2(rf_t *h, void * data, uint32_t nsamples , int8_t blocking, int8_t start_of_burst, int8_t end_of_burst ) ;

int rf_send(rf_t *h, void * data, uint32_t nsamples , int8_t blocking ) ;

int rf_send_timed(rf_t *h, void * data, int nsamples, time_t secs, double frac_secs );

int rf_send_timed2(rf_t *h, void * data, int nsamples , time_t secs, double frac_secs, int8_t is_start_of_burst, int8_t is_end_of_burst ) ;

int rf_send_timed_multi(rf_t *rf, void * *data, int nsamples, time_t secs, double frac_secs, int8_t blocking, int8_t is_start_of_burst, int8_t is_end_of_burst);

int rf_send_multi(rf_t *rf, void **data, int nsamples, int8_t blocking, int8_t is_start_of_burst, int8_t is_end_of_burst);

#ifdef __cplusplus
}
#endif

#endif //O5G_SRC_CCORE_PHY_RF_INCLUDE_RFAPI_H_
